<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>添加提币地址</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body {
            width: 100%;
            background-color: #ffffff;
            font-size: 0.28rem;
            height: auto;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: PingFangSC-Regular, sans-serif;
            color: #333333;
            box-sizing: border-box;
        }

        .addressBox {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
            padding: 0 0.3rem;
            box-sizing: border-box;
        }

        .chooseCoinType {
            width: 100%;
            height: 0.7rem;
            background: rgba(248, 248, 248, 1);
            border-radius: 0.04rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.24rem;
            box-sizing: border-box;
            margin-top: 0.47rem;
            font-size: 0.24rem;
            color: #9A9A9A;
        }

        .chooseCoinType span:first-of-type {
            color: #272727;
        }

        .chooseCoinType span:last-of-type {
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .chooseCoinType span:last-of-type img {
            width: 0.12rem;
            margin-left: 0.1rem;
        }

        input {
            outline: none;
            border: none;
            padding-left: 0;
            font-size: 0.28rem;
        }

        .addAdress {
            width: 100%;
            height: 1.7rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: space-between;
            border-bottom: 1px solid #E5E5E5;
            padding-top: 0.47rem;
            box-sizing: border-box;
            font-size: 0.28rem;
        }

        .addAdress p:last-of-type {
            flex: 1;
            width: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: stretch;
            justify-content: space-between;
        }

        .addAdress p:last-of-type input {
            flex: 1;
        }

        .addAdress p:last-of-type input::placeholder {
            color: #b2b2b2;
        }

        .addTypeCoin {
            width: 0.6rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-end;
        }

        .sureAddAdr {
            outline: none;
            border: none;
            width: 100%;
            height: 0.88rem;
            background: rgba(224, 224, 224, 1);
            border-radius: 0.08rem;
            font-size: 0.3rem;
            color: rgba(39, 39, 39, 1);
            margin-top: 0.58rem;
            line-height: 0.88rem;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="addressBox">
        <p class="chooseCoinType">
            <span class="coinName">
                BTC
            </span>
            <span class="chooseCoin">
                选择币种 <img src="../../image/right_jintou.png" alt="">
            </span>
        </p>
        <div class="addAdress">
            <p>
                地址
            </p>
            <p>
                <input type="text" name="adressText" id="adressText" placeholder="输入或粘贴BTC地址">
                <span class="addTypeCoin"><img src="../../image/iconsaomax.png" style="width: 0.3rem;"></span>
            </p>
        </div>
        <div class="addAdress">
            <p>
                备注
            </p>
            <p>
                <input type="text" name="notisText" id="notisText" placeholder="例:BTC 提币地址">
            </p>
        </div>
        <button class="sureAddAdr">
            确认
        </button>
    </div>
    <script src="../../script/autosize.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/jquery_three_two_one.js"></script>
    <script src="../../script/app.js"></script>
    <script>
        apiready = function () {
            var app = new APP();
            var account = app.getAccount();
            var chooseCoin = api.pageParam.coinName || "BTC", smsCodeNum = "";//选择添加地址的币种 短信验证码
            if (!$("#adressText").val()) {
                $("#adressText").attr("placeholder", "输入或粘贴" + chooseCoin + "地址");
            }
            if (!$("#notisText").val()) {
                $("#notisText").attr("placeholder", "例:" + chooseCoin + " 提币地址");
            }
            $(".coinName").text(chooseCoin);
            $(".chooseCoin").click(function () {
                var param = {
                    dtype: "dialog92",
                    stopPropagation: true
                }
                app.dialog(param);
            });
            function openScannerImg() {
                var FNScanner = api.require('FNScanner');
                FNScanner.openScanner({
                    autorotation: true,
                    isDrawQRCodeRect: true
                }, function (ret, err) {
                    if (ret) {
                        if (ret.eventType == "success" && ret.content) {
                            $("#adressText").val(ret.content);
                        }
                    } else {
                        app.toast("扫描失败");
                    }
                });
            }
            $(".addTypeCoin").click(function () {
                var appVersion = app.AV.split(".");
                if (Number(appVersion[0]) < 3) {
                    app.toast("请先升级到3.0.15版本以及以上");
                    return
                }
                if (Number(appVersion[2]) < 15) {
                    app.toast("请先升级到3.0.15版本以及以上");
                    return
                }
                var jurisdiction = api.hasPermission({
                    list: ['camera', 'photos']
                });
                if (jurisdiction[0].granted == false || jurisdiction[1].granted == false) {
                    api.requestPermission({
                        list: ['camera', 'photos'],
                        code: 1
                    }, function (ret, err) {
                        openScannerImg();
                    });
                } else {
                    openScannerImg();
                }
            });
            $(".addAdress input").on("input porpertychange", function (params) {
                if ($("#adressText").val() && $("#notisText").val()) {
                    $(".sureAddAdr").css("backgroundColor", "#fad203")
                } else {
                    $(".sureAddAdr").css("backgroundColor", "rgba(224, 224, 224, 1)")
                }
            });
            function addAdressUrl() {
                if (!smsCodeNum) {
                    app.toast("请输入短信验证码");
                    return
                }
                app.ajaxPro({
                    url: "member/add-tb-address",
                    values: {
                        token: account.token,
                        address: $("#adressText").val(),
                        currency_code: chooseCoin,
                        remark: $("#notisText").val(),
                        sms_code: smsCodeNum
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        app.toast("添加成功");
                        app.trigger("addAdrssSu");
                        setTimeout(function (params) {
                            app.closeW();
                        }, 1000)
                    } else {
                        app.toast(ret.message);
                    }
                })
            }
            $(".sureAddAdr").click(function () {
                if (!$("#adressText").val()) {
                    app.toast("请输入币种地址");
                    return
                }
                if (!$("#notisText").val()) {
                    app.toast("请输入币种地址备注");
                    return
                }
                var param = {
                    dtype: "dialog94",
                    data: {
                        phoneNum: account.telphone
                    },
                    stopPropagation: true
                }
                app.dialog(param);
            })
            app.listen("addresCoin", function (ret) {
                chooseCoin = ret.value;
                if (!$("#adressText").val()) {
                    $("#adressText").attr("placeholder", "输入或粘贴" + chooseCoin + "地址");
                }
                if (!$("#notisText").val()) {
                    $("#notisText").attr("placeholder", "例:" + chooseCoin + " 提币地址");
                }
                $(".coinName").text(ret.value);
            })
            app.listen("smsCodeNum", function (ret) {
                smsCodeNum = ret.value;
                addAdressUrl();
            })
            app.headerMap();
        }
    </script>
</body>

</html>